home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: seebs@solon.com (Peter Seebach)
- Newsgroups: comp.std.c,comp.lang.c.moderated
- Subject: Re: printf() format extensions - looking for beta testers...
- Date: 14 Apr 1996 23:44:18 -0500
- Organization: Usenet Fact Police (Undercover)
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4ksk72$rm6@solutions.solon.com>
- References: <4kll9l$o5h@solutions.solon.com> <4kobun$8i2@solutions.solon.com> <4koecq$8up@solutions.solon.com> <4kr74a$k8o@solutions.solon.com>
- Reply-To: seebs@solon.com
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4kr74a$k8o@solutions.solon.com>,
- Sean 'Captain Napalm' Conner <spc@gate.net> wrote:
- >>%# would be a poor choice; the conversion func for %# is one which returns
- >>a magic cookie to set the alternate format flag. :)
-
- > Oh. Ah. Well. What IS available?
-
- Whatever you want; it's just that if you change %#, you change the behavior
- of existing legal programs.
-
- > Well, why not change the approach? The current printf() will accept a
- >line such as:
-
- > printf("%*s",someint,somestring);
-
- > To allow variable widths to be specified. Why not extend that and pass in
- >the function pointers? Something like:
-
- > printf("%p@",myfunctptr,myptrtype);
-
- > Where '@' specifies a format function, and the letter before it declares
- >the type using a single letter specification:
-
- > c - char
- > s - short
- > i - int
- > l - long
- > f - float
- > d - double
-
- > With the following modifiers:
-
- > p - pointer (if alone, void *)
- > u - unsigned
-
- > Less chance of clashes, and more flexible I feel.
-
- Well, that would break existing code, of course; you can actually
- do something similar;
- int funcconv(va_list *ap, char *into, int len, fmtspec *fs) {
- fmtconv fc;
-
- fc = va_arg(*ap, fmtconv);
- return fc(ap, into, len, fs);
- }
-
- And just bind this to whatever character you want. (In my sample
- implementation, it's %<.)
-
- -s
- --
- Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
- C/Unix wizard -- C/Unix questions? Send mail for help. No, really!
- FUCK the communications decency act. Goddamned government. [literally.]
- The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
-